// pages/level-scene/list/list.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    CDNPATH:app.globalData.CDNPATH,
    sceneList: [],
    levelId: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const { levelId,levelName } = options
    wx.setNavigationBarTitle({
      title: levelName
    })
    this.setData({
      levelId
    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getLevalSceneList()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  getLevalSceneList () {
    app.api.get({
      url: 'qry_user_level_scene',
      data: {
        levelId: this.data.levelId
      }
    }).then(res => {
      const arr = res || []
        this.setData({ 
          sceneList: arr,
          noData: arr.length==0
        })    
    })
  },
  learn (e) {
    const { sceneId, sceneName } = e.currentTarget.dataset.item
    console.log(this.data.levelId)
      wx.navigateTo({
        url: `/pages/train/learning-link/learningLink?sceneId=${sceneId}&sceneName=${sceneName}&isRecommended=N&recordType=level&userClassify=level&from=level&levelId=${this.data.levelId}`
      })
  },
  train (e) {
    const { sceneId, sceneName } = e.currentTarget.dataset.item
    const type = 'train'
    wx.navigateTo({
      // url: `/pages/train/only-train/onlyTrain?sceneId=${sceneId}&sceneName=${sceneName}&userClassify=${userClassify}&customerSex=${customerSex}&coachingContentId=${coachingContentId}&trainingLibraryId=${trainingLibraryId}&type=${type}&description=${description}&descInfo=${descInfo}&from=${this.data.from}`
      url: `/pages/train/only-train/onlyTrain?sceneId=${sceneId}&sceneName=${sceneName}&isRecommended=N&userClassify=level&from=level&type=${type}&levelId=${this.data.levelId}`
    })
  },
  exam (e) {
    const { sceneId, sceneName } = e.currentTarget.dataset.item
    const type = 'exam'
    wx.navigateTo({
      // url: `/pages/train/exam/exam?sceneId=${sceneId}&sceneName=${sceneName}&userClassify=${userClassify}&customerSex=${customerSex}&coachingContentId=${coachingContentId}&trainingLibraryId=${trainingLibraryId}&type=${type}&description=${description}&descInfo=${descInfo}`
      url: `/pages/train/exam/exam?sceneId=${sceneId}&sceneName=${sceneName}&isRecommended=N&userClassify=level&from=level&type=${type}&levelId=${this.data.levelId}`
    })
  },

})